package com.hw01.controller;

import java.time.LocalDateTime;
import java.util.List;

import com.hw01.vo.ClockInVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.hw01.common.Result;
import com.hw01.service.PunchingCardRecordService;
import com.hw01.vo.PunchingCardRecordVo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * 打卡记录管理
 */
@RestController
@Api("打卡记录管理")
@RequestMapping("/punchingCardRecord")
public class PunchingCardRecordController {

    @Autowired
    PunchingCardRecordService punchingCardRecordService;

    @GetMapping("/getList")
    @ApiOperation("获取打卡记录")
    @ResponseBody
    public Result<List<PunchingCardRecordVo>> getPunchingCardRecord(
        @ApiParam(value = "员工用户id") Long userId, @ApiParam(value = "年份(数字)") String year,
        @ApiParam(value = "月份(数字)") String month) {
        return punchingCardRecordService.getPunchingCardRecord(userId, year, month);
    }

    @GetMapping("/clockIn")
    @ApiOperation("打卡")
    @ResponseBody
    public Result<LocalDateTime> clockIn(@ApiParam(value = "员工用户id", required = true) Long userId,
                                         @ApiParam(value = "打卡地点") String address) {
        return punchingCardRecordService.clockIn(userId,address);
    }

    @GetMapping("/todayClockIn")
    @ApiOperation("今日是否打卡")
    public Result<ClockInVo> todayClockIn(@ApiParam(value = "员工用户id", required = true) Long userId) {
        return punchingCardRecordService.todayClockIn(userId);
    }

}
